i like to ask for advise how to let this array [1,2,3,4] to become 12, 23, 34?
this initial is a number 1234, i split them
let sum
sum = String(this.numbers).split("").map(Number);
console.log('numbers set1', sum)
so from here it becomes [1,2,3,4]
how can i join/combine/concat then to become 12, 23, 34 respectively?
thank you very much for Hello World's guidance
thank you
You may want to write simple algorithm to get pairs of those numbers. Try to traverse the string/list and insert the new values into another list.
Sudo code can be something like: let's say you have arr with numbers [1,2,3,4]
for i = 1 to N:
string sum = arr[i-1]+arr[i];
list.push(sum)
var arr=[1,2,3,4];
var list=[];
for(i=1;i<arr.length;i++){
let sum = parseInt(arr[i-1].toString()+arr[i].toString())
list.push(sum)
}
console.log(list);